package com.weiai.wedding.dao.user;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.PersistenceContext;

import org.springframework.orm.jpa.support.JpaDaoSupport;
import org.springframework.stereotype.Component;

import com.weiai.wedding.util.StatusConstants;
/**
 * 菜单查询实现类
 * @author wangweiheng
 *
 */
@Component
public class AuthExpaDaoImpl implements AuthExpaDao {

	@PersistenceContext
	private EntityManager em;
	@Override
	public List findListByLoginName(String loginName) {
		// TODO Auto-generated method stub
		StringBuffer sql = new StringBuffer();
		sql.append("select distinct a.* from auth_t a,user u,user_auth ua ");
		sql.append("where u.id = ua.user_id  and ua.auth_code = a.auth_code and a.auth_Type = 'A' and u.status='"+StatusConstants.AUDITED+"' and u.login_name = '");
		sql.append(loginName);
		sql.append("' order by a.sort_id");
        List result = em.createNativeQuery(sql.toString()).getResultList();
        
		return result;
	}

}
